import cv2
import matplotlib.pyplot as plt

# 读取彩色图像并转换为灰度图像
color_image = cv2.imread('./lena.png')
gray_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2GRAY)

kernel_size = (9, 9)
sigma = 3

# 应用均值滤波
# blurred_image = cv2.blur(gray_image, kernel_size)
# blurred_image = cv2.GaussianBlur(gray_image, kernel_size, sigma)
blurred_image = cv2.Laplacian(gray_image, cv2.CV_64F)

# 显示原始图像
plt.imshow(gray_image, cmap='gray')
plt.title('Original Image')
plt.axis('off')
plt.show()

# 显示处理后的图像
plt.imshow(blurred_image, cmap='gray')
plt.title('Transformed Image')
plt.axis('off')
plt.show()
